<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="../template/taglib.jsp"%>
<jsp:include page="../template/header.jsp" />

<jsp:include page="../template/staffmenu.jsp" />

<%-- content template --%>
<jsp:include page="../template/contentheader.jsp" />
<%-- put content here --%>
<link href="/css/style.css" rel="stylesheet" type="text/css" />
<fmt:setBundle basename="staff" />
<form
	action="/LeaveApplicationProcessingSystem/ManagePersonalLeaveServlet"
	method="post">
	<h1>
		<fmt:message key="lable.leave.manage" />
	</h1>
	<table>
		<tr>
			<td align="left">View By Status:</td>
			<td colspan="2"><select name="status">
					<option value="0"
						<c:if test="${currentstatus == 0}">SELECTED</c:if>>All</option>
					<option value="1"
						<c:if test="${currentstatus == 1}">SELECTED</c:if>>Approved</option>
					<option value="2"
						<c:if test="${currentstatus == 2}">SELECTED</c:if>>Applied</option>
					<option value="3"
						<c:if test="${currentstatus == 3}">SELECTED</c:if>>Canceled</option>
					<option value="4"
						<c:if test="${currentstatus == 4}">SELECTED</c:if>>Rejected</option>
					<option value="5"
						<c:if test="${currentstatus == 5}">SELECTED</c:if>>Updated</option>
			</select> &nbsp;&nbsp;<input type="submit" value="Show" name="btnsearch" /></td>

		</tr>
		<tr>
			<td colspan="3">&nbsp;</td>
		</tr>
		<tr>
			<!-- <th><fmt:message key="lable.staff.id" />
			</th> -->
			<th><fmt:message key="lable.leave.type" /></th>
			<th><fmt:message key="lable.leave.startdate" /></th>
			<th><fmt:message key="lable.leave.enddate" /></th>
			<th><fmt:message key="lable.leave.natureofleave" /></th>
			<th><fmt:message key="lable.leave.status" /></th>
			<th>&nbsp;</th>
		</tr>
		<c:forEach var="status" items="${leave}">
			<tr>
				<!-- <td>${status.id}</td> -->
				<td>${status.leaveTypeName}</td>
				<td><fmt:formatDate pattern="yyyy-MM-dd"
						value="${status.startDate}" /></td>
				<td><fmt:formatDate pattern="yyyy-MM-dd"
						value="${status.endDate}" /></td>
				<td>${status.natureOfLeaveName}</td>
				<c:if test="${status.status == 1}">
					<td>Approved</td>
				</c:if>
				<c:if test="${status.status == 2}">
					<td>Applied</td>
				</c:if>
				<c:if test="${status.status == 3}">
					<td>Canceled</td>
				</c:if>
				<c:if test="${status.status  == 4}">
					<td>Rejected</td>
				</c:if>
				<c:if test="${status.status  == 5}">
					<td>Updated</td>
				</c:if>

				<c:if test="${status.status != 3 && status.status != 4}">
					<td><c:url var="updateLeaveurl" scope="page"
							value="/staff/applyLeave.jsp">
							<c:param name="id" value="${status.id}" />
							<c:param name="leaveType" value="${status.leaveType}" />
							<c:param name="startDate" value="${status.startDate}" />
							<c:param name="endDate" value="${status.endDate}" />
							<c:param name="natureOfLeave" value="${status.natureOfLeave}" />
							<c:param name="status" value="${status.status}" />
							<c:param name="reason" value="${status.reason}" />
							<c:param name="workDisemmination"
								value="${status.workDisemmination}" />
							<c:param name="contactDetails" value="${status.contactDetails}" />

							<c:param name="update" value="true" />
						</c:url> <a href="${updateLeaveurl}"><fmt:message
								key="lable.staff.modify" /> </a> &nbsp;&nbsp;&nbsp;&nbsp; <c:url
							var="cancelLeaveurl" value="/CancelStatusServlet">
							<c:param name="id" value="${status.id}" />
							<c:param name="changestatus" value="3" />
						</c:url> <a href="${cancelLeaveurl}"><fmt:message
								key="lable.staff.cancel" /> </a></td>
				</c:if>
				<c:if test="${status.status == 4}">
					<td><c:url var="urlDetail" scope="page"
						value="/staff/manageDetailLeave.jsp">
						<c:param name="id" value="${status.id}" />
						<c:param name="name" value="${status.username}" />
						<c:param name="leaveType" value="${status.leaveType}" />
						<c:param name="startDate" value="${status.startDate}" />
						<c:param name="endDate" value="${status.endDate}" />
						<c:param name="natureOfLeave" value="${status.natureOfLeaveName}" />
						<c:param name="reason" value="${status.reason}" />
						<c:param name="workDisemmination"
							value="${status.workDisemmination}" />
						<c:param name="contactDetails" value="${status.contactDetails }" />
						<c:param name="status" value="${status.status}" />
						<c:param name="comment" value="${status.comment}" />
						<c:param name="back" value="/LeaveApplicationProcessingSystem/ManagePersonalLeaveServlet" />
					</c:url>
					<a href="${urlDetail}"><fmt:message key="lable.staff.detail" /></a></td>
				</c:if>
			</tr>
		</c:forEach>
	</table>
</form>
<jsp:include page="../template/contentfooter.jsp" />
<%-- end of content template --%>

<jsp:include page="../template/footer.jsp" />

